package com.grow.greenhouse.controller;

import com.grow.greenhouse.common.BaseResponse;
import com.grow.greenhouse.utils.QiNiuCloudUtil;
import com.grow.greenhouse.utils.ResultUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/test")
public class TestQiNiuCloudController {
    //上传图片
    @PostMapping("/test1")
    public BaseResponse<Object> test1(@RequestParam("file") MultipartFile file) throws Exception {
        return ResultUtils.success(QiNiuCloudUtil.QiniuCloudUploadImage(file));
    }

    //获取图片链接
    @PostMapping("/test2")
    public BaseResponse<Object> test2(@RequestParam("fileName") String fileName){
        return ResultUtils.success(QiNiuCloudUtil.QiniuCloudDownloadImage(fileName)) ;
    }

    //删除图片
    @PostMapping("/test3")
    public BaseResponse<Object> test3(@RequestBody String[] fileNameList){
        return ResultUtils.success(QiNiuCloudUtil.QiniuCloudDeleteImage(fileNameList));
    }

}
